﻿@Imports SchoolClick.Database.jqGrid
@Code
    Dim grid = New JqGridHelper(Of DEF_PROFESOR_IMPARTE_MATERIA)("tbl-prof-materia",
       dataType:=JqGridDataTypes.Json, methodType:=JqGridMethodTypes.Post, pager:=True,
       rowsNumber:=15,
       viewRecords:=True,
       rowsNumbers:=True,
       width:=920, height:=400,
       onSelectRow:="$.handlerjqGridOnSelectedRowForNotas"
    ).Navigator(New JqGridNavigatorOptions() With {.Add = False, .Edit = False, .Delete = False, .Search = False}
    ).InlineNavigator(New JqGridInlineNavigatorOptions() With {.Edit = True, .Add = False})
End Code

@Html.TableFields(String.Format("Grados del año escolar {0}", ViewBag.Year)
    ).AddField("cmbGrados", "Selección el grado y sección para definir al profesor", JFControlType.ComboBox, New JFOptionsFields(
               ).setSource(Url.Action("_getGradosAndSecciones_AJAX", "AnioEscolar", New With {.year = ViewBag.Year}))
).SetTableWidth(920
).AddJavaScript(String.Format("$('#jerti-content').attr('data-year-ae', {0});", ViewBag.Year)
).AddJavaScript(grid.GetJavaScript.ToHtmlString)
@grid.GetHtml
<script type="text/javascript">
    $(function () {
        $('#cmbGrados').on({
            change: function () {
                $('#tbl-prof-materia').jqGrid('setGridParam', { url: '/AnioEscolar/_get_materias_by_idgrado_ae?Grado=' + this.value + '&Year=' + $('#jerti-content').attr('data-year-ae') }).trigger('reloadGrid').jqGrid('setGridParam', { editurl: '/AnioEscolar/_asignar_profesor_materia_gradoseccion?IDGrado=' + this.value + '&Year=' + $('#jerti-content').attr('data-year-ae') });
            }, loadSuccess: function () {
                $('#tbl-prof-materia').jqGrid('setGridParam', { url: '/AnioEscolar/_get_materias_by_idgrado_ae?Grado=' + this.value + '&Year=' + $('#jerti-content').attr('data-year-ae') }).trigger('reloadGrid').jqGrid('setGridParam', { editurl: '/AnioEscolar/_asignar_profesor_materia_gradoseccion?IDGrado=' + this.value + '&Year=' + $('#jerti-content').attr('data-year-ae') });
            }
        });
    });
</script>
<br />
<br />